﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using HighDivePrinter.Model;
using HighDivePrinter.Properties;

using System.Xml;
using System.Xml.Serialization;
using System.ComponentModel;

namespace HighDivePrinter.Model
{
    [Serializable()]
    public class Diver :  IComparable<Diver> //Person
    {
        #region Properties
        /// <summary>
        /// Diver information 
        /// </summary>
        /// 

        private int? _StartNumber;
        private int? _DbId;

        private int? _PersonDbId;
        private string _IdNumber;
        private string _FirstName;
        private string _LastName;
        private Gender _Gender;
        private string _Club;
        private string _Email;
        private string _Address;

      /*  public int? PersonDbId
        {
            get
            {
                return _PersonDbId;
            }
            set
            {
                _PersonDbId = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("PersonDbId"));
            }
        }*/
        public string IdNumber 
        {
            get
            {
                return _IdNumber;
            }
            set
            {
                _IdNumber = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("IdNumber"));
            }
        }

        public int? StartNumber
        {
            get
            {
                return _StartNumber;
            }
            set
            {
                _StartNumber = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("StartNumber"));
            }
        }
        public string FirstName 
        {
            get
            {
                return _FirstName;
            }
            set
            {
                _FirstName = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("FirstName"));
            }
        }
        public string LastName 
        {
            get
            {
                return _LastName;
            }
            set
            {
                _LastName = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("LastName"));
            }
        }
        public Gender Gender 
        {
            get
            {
                return _Gender;
            }
            set
            {
                _Gender = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Gender"));
            }
        }
      /*  public string Club 
        {
            get
            {
                return _Club;
            }
            set
            {
                _Club = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Club"));
            }
        }*/
        public string Email 
        {
            get
            {
                return _Email;
            }
            set
            {
                _Email = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Email"));
            }
        }
        public string Address 
        {
            get
            {
                return _Address;
            }
            set
            {
                _Address = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Address"));
            }
        }
       
        /*public int? DbId 
        {
            get
            {
                return _DbId;
            }
            set
            {
                _DbId = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new PropertyChangedEventArgs("DbId"));
            }
        }*/

        #endregion

        #region Constructor region
        /// <summary>
        /// Default constructor
        /// </summary>
        public Diver(string idNumber, string firstName, string lastName, Gender gender, int? startNumber = null, string address = null, string club = null,
            string email = null)
            //: base(idNumber, firstName, lastName, gender, address, club, email)
        {
            this.IdNumber = idNumber;
            this.FirstName = firstName;
            this.LastName = lastName;
            this.Gender = gender;
            this.Address = address;
           // this.Club = club;
            this.Email = email;
            //this.PersonDbId = -1;
            this.StartNumber = startNumber;
            //this.DbId = null;
        }

        public Diver()
        {

        }

        #endregion

        #region IComparable Members

        /// <summary>
        /// Method that defines comparison of two Diver.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
       public int CompareTo(Diver obj)
        {
            int c = this.StartNumber.Value.CompareTo(obj.StartNumber.Value);
            if (c == 0)
                return this._FirstName.CompareTo(obj._FirstName);
            else
                return c;
        }

        #endregion   

        #region INotifyPropertyChanged Members
        /// <summary>
        /// Event declaration.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion


    }
}
